package com.andaily.ccg.infrastructure;

import javax.swing.*;
import java.awt.*;

/**
 * @author Shengzhao Li
 */
public abstract class SwingUtil {


    /**
     * 根据界面的长度与宽度确定界面的左上角坐标值
     *
     * @param width  长度
     * @param height 宽度
     * @return Point
     */
    public static Point getStartPoint(int width, int height) {
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        dim.width = dim.width / 2 - width / 2;
        dim.height = dim.height / 2 - height / 2;
        return new Point(dim.width, dim.height);
    }

    /**
     * 设置UI WindowsLookAndFeel
     */
    public static void setUI() {
        try {
            String ui = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
            UIManager.setLookAndFeel(ui);
            JFrame.setDefaultLookAndFeelDecorated(true);
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    }

}